<template>
	<view class="container">
		<carHeader style="padding:10rpx;"
		  :title="'详情'"></carHeader>
		  
		<view class="repairInfo" >
			<view class="one">
				<text>维修信息</text>
			</view>
			<view class="info">
				<text v-model="form1.ddNumber">维修单号：{{form1.ddNumber}}</text>
			</view>
			<view class="info">
				<text>车主姓名：{{form1.user.uName}}</text>
			</view>
			<view class="info">
				<text>联系方式：{{form1.user.pNumber}}</text>
				<uni-icons type="phone-filled"
				 size="20" 
				 color="#3082FB"
				 style="float: right;margin-right: 20px;">
				 </uni-icons>
			</view>
			<view class="info">
				<text>维修方式：{{form1.serviceNames}}</text>
			</view>
			<view class="info">
				<text>取车位置：{{form.address}}</text>
				<uni-icons type="paperplane-filled"
				 size="20" 
				 color="#3082FB"
				 style="float: right;margin-right: 20px;">
				 </uni-icons>
			</view>
			<view class="info">
				<text>预约日期：{{form1.ddYuyueTime}}</text>
			</view>
			<view class="info">
				<text>提交日期：{{form1.ddHexiaoTime}}</text>
			</view>
			<view class="info">
				<text v-if="isShow">到场日期：{{form1.ddAddtime}}</text>
			</view>
			  
		</view>
		
		<view class="carInfo">
			<view class="one">
				<text>车辆信息</text>
			</view>
			<view class="info">
				<text>车辆类型：{{form1.yonghucheliang.yhclType}}</text>
			</view>
			<view class="info">
				<text>车牌号：{{form1.yonghucheliang.yhclCarNum}}</text>
			</view>
			<view class="info">
				<text>整车照片：\n</text>
				<image :src="form1.yonghucheliang.carImg"></image>
			</view>
			<view class="info">
				<text>维修部位照片：\n</text>
				<view v-for="(item,index) in carForm.repairPhotos" :key="index"
				style="display: inline-block;">
					<image :src="item.photo"></image>
				</view>
				
			</view>
			
		</view>
		
		<view class="btn">
			<u-button @click="dialogToggle('info')"
			:disabled="isVerified"
			type="primary" 
			:color="isVerified ? '#808080' : '#0662E6'"
			shape="circle" 
			>
			{{isVerified ? '已到场' : '确认到场'}}</u-button>
			<!-- <view v-else>已核销</view> -->
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				form1:{
					
				},
				form:{
					repairNumber:"3535252",
					name:"张",
					phone:"1993829282",
					repairMethod:"上门取车/到店维修",
					address:"山阳区32号",
					appointmentTime:"2022/11/10 11:00",
					submitTime:"2022/11/08 12:34",
					comeTime:"",
					// serviceNames:this.form1.serviceNames,
				},
				carForm:{
					carType:"大客车",
					carNumber:"豫J45323",
					carPhoto:"/static/车联网服务商家端-00登录_slices/组 6(1).png",
					repairPhotos:[
						{
							photo:"/static/车联网服务商家端-00登录_slices/组 6(1).png"
						},
						{
							photo:"/static/车联网服务商家端-00登录_slices/组 6(1).png"
						},
						{
							photo:"/static/车联网服务商家端-00登录_slices/组 6(1).png"
						},
						
					]
				},
				msgType:"info",
				isVerified:false,
				isShow:false,
			};
		},
		created() {
			
		},
		onLoad: function(option) {
		 //  const eventChannel = this.getOpenerEventChannel();
		 //  eventChannel.emit('acceptDataFromOpenedPage', {data: 'data from test page'});
		 //  eventChannel.emit('someEvent', {data: 'data from test page for someEvent'});
		 //  // 监听acceptDataFromOpenerPage事件，获取上一页面通过eventChannel传送到当前页面的数据
		 //  eventChannel.on('acceptDataFromOpenerPage', function(data) {
			// console.log("-------------------------")
		 //    console.log(data.data.item)
			// this.form1 = data.data.item
			// console.log(this.form1)
		 //  })
		 		// options 是由 uni-app 框架在页面加载时自动传递的，包含了从上一个页面传递过来的参数 
		 			console.log(option)
		 			const obj = JSON.parse(decodeURIComponent(option.data));
		 			console.log(obj);
					this.form1=obj;
		 			// this.list =obj;
		 			// console.log("--------------------");
		 			// console.log(this.list)
		 			// this.title = obj.title;
		 			// console.log(this.title)

		},
		methods:{
			dialogToggle(type) {
				console.log(this.form1);
				this.msgType = type
				console.log(type);
				this.isVerified=true;
				const now = new Date();
				this.form.comeTime = now.toLocaleString(); 
				console.log(this.isShow);
				// console.log(this.form.comeTime);
				this.form = this.form.comeTime;
				console.log(this.form);
				
				//修改状态的请求
				uni.request({
					url: 'http://localhost:8080/shop/weixiurenwu/update',
					method: 'POST',
					data: {
						status: 2,
						ddId:this.form1.ddId,
					},
					success: (res) => {
						console.log("修改成功")
						console.log(res.data.rows)
					},
				});
			},
		}
	}
</script>

<style lang="scss">
	.repairInfo{
		background-color: white;
		height: 650rpx;
		width: 95%;
		position: absolute;
		top: 150rpx;
		left: 20rpx;
		border-radius: 20rpx;
		z-index: 1;
		.one{
			padding: 20rpx 30rpx;
			border-bottom: 5px solid #F9F9F9;
		}
		.info{
			margin: 30rpx 30rpx;
			font-size: 13px;
		}
	}
	
	.carInfo{
		margin-left: 20rpx;
		margin-right: 20rpx;
		margin-top: 460rpx;
		background-color: white;
		height: 800rpx;
		width: 95%;
		// position: absolute;
		// top: 700rpx;
		// left: 20rpx;
		border-radius: 20rpx;
		z-index: 1;
		.one{
			padding: 20rpx 30rpx;
			border-bottom: 5px solid #F9F9F9;
		}
		.info{
			margin: 30rpx 30rpx;
			font-size: 13px;
			image{
				width: 80px;
				height: 80px;
				margin: 10px 10px;
			}
		}
	}
	
	.btn{
		margin: 40px auto;
		width: 70%;
	}
	
</style>
